import { dayis } from "element-plus";
import { start } from "nprogress";
import moment  from "moment/moment";

//中国标准时间转换为yy-mm-dd
export let conversion = (date) => {   
    var YY = date.getFullYear() + '-';
    var MM =
        (date.getMonth() + 1 < 10
            ? '0' + (date.getMonth() + 1)
            : date.getMonth() + 1) + '-';
    var DD = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
    return YY + MM + DD
}

//中国标准时间转换为yy-mm
export let YYMM = (date) => {   
    var YY = date.getFullYear() + '-';
    var MM =
        (date.getMonth() + 1 < 10
            ? '0' + (date.getMonth() + 1)
            : date.getMonth() + 1) 
    return YY + MM 
}


export let conversionDateTime=(timestamp)=>{
   // 使用JavaScript的Date对象将时间戳格式化为某年-某月-某日 某时:某分:某秒
   const date = new Date(timestamp.year, timestamp.monthValue - 1, timestamp.dayOfMonth, timestamp.hour, timestamp.minute, timestamp.second);
   const year = date.getFullYear();
   const month = (date.getMonth() + 1).toString().padStart(2, '0'); // 补零
   const day = date.getDate().toString().padStart(2, '0');
   const hours = date.getHours().toString().padStart(2, '0');
   const minutes = date.getMinutes().toString().padStart(2, '0');
   const seconds = date.getSeconds().toString().padStart(2, '0');
   return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}

//表格时间搓传日期时间格式
export let dateFormatter=(row,column)=>{
  var date=row[column.property];
  return moment(date).format("YYYY-MM-DD HH:mm:ss")
}

// 时间搓转年月日
export let dateYMD=(row,column)=>{
  var date=row[column.property];
  return moment(date).format("YYYY-MM-DD ")
}



//今天之前包括今天可选
export let beforeTodayAnd=(time) => {
    if (time.getTime() > Date.now() ) {
      return true;
    } else {
      return false;
    }
  };

//今天之前包括今天可选
export let afterTodayAnd=(time) => {
    if (time.getTime() < Date.now() ) {
      return true;
    } else {
      return false;
    }
  };
//今天之前可选
export let beforeToday=(time) => {
    if (time.getTime() > Date.now() - 8.64e7) {
      return true;
    } else {
      return false;
    }
  };

//今天之前可选
export let afterToday=(time) => {
    if (time.getTime() < Date.now() - 8.64e7) {
      return true;
    } else {
      return false;
    }
  };